<?php

namespace Blog\App\Model;

use Hx\App;

/**
 * 用户操作类
 * Class User
 * @package Blog\App\Model
 */
class User {

    /**
     * 数据库对象
     * @var \Hx\Db
     */
    private $db;

    /**
     * 构造函数
     */
    public function __construct() {
        $this->db = App::Db();
    }

    /**
     * 获取一个用户数据
     * @param $key
     * @param $value
     * @return mixed
     */
    public function getOne($key, $value) {
        $sql = App::Sql('HxSite_User', 'user,nickName,avatar,desc,userRole')
            ->where('status = "public"')
            ->where($key . ' = :' . $key)
            ->select();
        return $this->db->query($sql, array($key => $value));
    }

}